"""
@title(TenX腾晓2024年12月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
@license(CC BY-SA 4.0 License)
"""
import os
from copy import deepcopy
from typing import List


class TenXClass:
    def __init__(self):
        # 获取当前文件名并截取文件名的学号-姓名
        file_name = os.path.basename(__file__).split('.')[0].split("-")
        self.id = file_name[0]  # 学号
        self.name = file_name[1]  # 姓名

    @staticmethod
    def question1(*args) -> list[str]:
        binary_tree = deepcopy(args[0])  # 传入的地牢结构（二叉树），详细请看BinaryTree.py
        root = binary_tree.root
        if not root:
            return []
        string_paths = []
        a = [(root, [])]
        while a:
            node, path = a.pop()
            path = path + [node.value]
            if not node.left and not node.right and node.value == 0:
                # 将路径中的元素转换为字符串并拼接
                spath = ''.join(str(item) for item in path)
                string_paths.append(spath)
            if node.right:
                a.append((node.right, path))
            if node.left:
                a.append((node.left, path))
        return string_paths

    @staticmethod
    def question2(*args) -> str:
        matrix = deepcopy(args[0])  # 传入的河流结构（矩阵）
        j = ""
        for i in matrix:
            j += str(max(i))

        return j

    @staticmethod
    def question3(*args) -> int:
        count = 0
        min_num = 10 ** 999
        max_num = 10 ** 9999 - 1
        for i in range(min_num, max_num):
            a = str(i)
            if "1" and "2" and "6" not in a:
                count += 1
            return count % 99999999

    @staticmethod
    def question4(*args) -> int:
        n = deepcopy(args[0])  # 用于搭建金字塔的球个数
        i = 1
        floor = 0
        while i:
            a = sum(range(i + 1))  # 每一层的珠子数量
            if n >= a:
                floor += 1
                i += 1
                n = n - a
            else:
                i = False
                return floor

    @staticmethod
    def question5(*args) -> list[str]:
        balls = deepcopy(args[0])  # 五行空间球的初始值
        while min(balls) < 10000:
            for i in balls:
                if i < 10000:
                    index = balls.index(i)
                    balls[index] = balls[index - 1] + balls[index - 2]
        return list(map(str, balls))
